private static final CHANNEL_ID="buraya bulunduğun paket ismini yaz"
private static final CHANNEL_NAME="Buraya istedigin şeyi yazabilrisin"
//Yukarıdakileri globale yani oncreate metodunun üstüne yazmalısın//
NotificationChannel channel= new NotificationChannel(CHANNEL_ID, CHANNEL_NAME, NotificationManager.IMPORTANCE_DEFAULT); channel.enableLights(true); channel.enableVibration(true); .setLightColor(getColor(R.color.blue)); channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE); getManager().createNotificationChannel(channel); getManager().createNotificationChannel(channel); NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); Intent intentactivity = new Intent(getApplicationContext(), Gideceginsınıf.class); PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(),0, intentactivity, 0); mNotificationManager.createNotificationChannel(channel); Notification notification = new NotificationCompat.Builder(getApplicationContext()) .setSmallIcon(bildirim iconu) .setContentTitle("Bildirim basligi") .setContentText("Bildirim yazısı") .setContentIntent(pendingIntent) .setAutoCancel(true) .setChannelId(CHANNEL_ID).build(); mNotificationManager.notify(0, notification);
//Alttaki koduda en sona bir yere metotların altına yaz fakat classın içinde olmalı//
public NotificationManager getManager() { if(manager==null){ manager=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE); } return manager; }